<template>
  <div class="base-b">
    <div>我是B组件（发布方）</div>
    <button @click="sendFn">发布消息</button>
  </div>
</template>

<script>
import Bus from "./../utils/EventBus.js";
export default {
  methods: {
    sendFn() {
      // 1. 利用事件总线发布消息
      // Bus.$emit('事件名', 消息)
      Bus.$emit("sendMsg", { id: 1, msg: "湖人凉了" });
    },
  },
};
</script>

<style scoped>
.base-b {
  width: 200px;
  height: 200px;
  border: 3px solid #000;
  border-radius: 3px;
  margin: 10px;
}
</style>